package me.jessyan.mvparms.demo.mvp.ui.activity.account;

import android.content.Intent;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;

import me.jessyan.mvparms.demo.R;
import me.jessyan.mvparms.demo.mvp.ui.widget.CustomToolbar;
import me.jessyan.mvparms.demo.mvp.ui.widget.MyVerifyLinerText;
import me.jessyan.mvparms.demo.utils.PerfectClickListener;

/**
 * 短信验证
 */
public class SmsVeriftyActivity extends BaseActivity {


    CustomToolbar toolbar;
    MyVerifyLinerText verifyLl;
    TextView sureTv;
    TextView verifyAskingTv;
    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {

    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_sms_verifty;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

        verifyAskingTv=      findViewById(R.id.verify_asking_tv);
        verifyLl = findViewById(R.id.verify_ll);
        toolbar = findViewById(R.id.toolbar);
        sureTv = findViewById(R.id.sure_tv);
        toolbar.setListener(new CustomToolbar.ToolbarListener() {
            @Override
            public void onLeftBack() {
                finish();
            }

            @Override
            public void onRightBack() {

            }
        });

        //验证码
        verifyLl.setVerifyListener(new MyVerifyLinerText.VerifyListener() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (s.length() == 4) {
                     sureTv.setEnabled(true);
                } else {
                  sureTv.setEnabled(false);
                }
            }
            @Override
            public void onClick(View view) {
                verifyLl.startTimer();
            }
        });

        sureTv.setOnClickListener(new PerfectClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                startActivity(new Intent(SmsVeriftyActivity.this,PassWrodActivity.class));
            }
        });
        verifyAskingTv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        verifyAskingTv.setOnClickListener(new PerfectClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                startActivity(new Intent(SmsVeriftyActivity.this,VerifyAskingActivity.class));
            }
        });
    }
}
